package com.nuo.modules.surveyresult.controller;

import java.util.Arrays;
import java.util.Map;

import com.nuo.common.excel.po.ExportListPo;
import com.nuo.modules.surveyresult.po.OkPo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.nuo.modules.surveyresult.entity.SurveyResultEntity;
import com.nuo.modules.surveyresult.service.SurveyResultService;
import com.nuo.common.utils.PageUtils;
import com.nuo.common.utils.R;
import org.springframework.web.multipart.MultipartFile;


/**
 * 
 *
 * @author nuo
 * @email 3033616351@qq.com
 * @date 2022-11-04 17:06:38
 */
@RestController
@RequestMapping("surveyresult")
public class SurveyResultController {
    @Autowired
    private SurveyResultService surveyResultService;

    /**
     * 学生确认检测结果
     */
    @PostMapping("/ok")
    public R ok(@RequestBody OkPo po){
        return surveyResultService.ok(po);
    }

    /**
     * 前台获取检测结果列表
     */
    @PostMapping("/getList")
    public R getList(@RequestBody Map<String, Object> params){
        return surveyResultService.getList(params);
    }

    /**
     * 导入学生信息
     */
    @PostMapping("/importList")
    public R importList(@RequestParam("file") MultipartFile file){
        return surveyResultService.importList(file);
    }

    /**
     * 导出问卷结果信息
     */
    @PostMapping("/exportList")
    public R exportList(@RequestBody ExportListPo<SurveyResultEntity> po){
        return surveyResultService.exportList(po);
    }

    /**
     * 导出全部问卷结果信息
     */
    @RequestMapping("/exportAll")
    public R exportAll(){
        return surveyResultService.exportAll();
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
        public R list(@RequestParam Map<String, Object> params){
        PageUtils page = surveyResultService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
        public R info(@PathVariable("id") Long id){
		SurveyResultEntity surveyResult = surveyResultService.getById(id);

        return R.ok().put("surveyResult", surveyResult);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
        public R save(@RequestBody SurveyResultEntity surveyResult){
		surveyResultService.save(surveyResult);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
        public R update(@RequestBody SurveyResultEntity surveyResult){
		surveyResultService.updateById(surveyResult);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
        public R delete(@RequestBody Long[] ids){
		surveyResultService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
